﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Security.Cryptography;
using System.Text;

namespace ZWZ.Web.Codes
{
    public static class IDHelper
    {
        public static string GetMd5_16(string str)
        {
            var md5 = new MD5CryptoServiceProvider();
            return BitConverter.ToString(md5.ComputeHash(UTF8Encoding.UTF8.GetBytes(str)), 4, 8).Replace("-", "").ToUpper();
        }

        public static string CreateID()
        {
            return GetMd5_16(Guid.NewGuid().ToString());
        }

        public static string CreateTimeID()
        {
            return DateTime.Now.ToString("yyyyMMddHHmmssffff");
        }

        public static string CreateID_UserInfo() {
            return "UI" + CreateID();
        }
        public static string CreateID_FileInfo()
        {
            return "FI" + CreateID();
        }
        public static string CreateID_UserMessage()
        {
            return "UM" + CreateID();
        }
        public static string CreateID_PageInfo()
        {
            return "PG" + CreateID();
        }
    }
}